package demo1;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.lang.reflect.Method;

public class Demo {
    public static void main(String[] args) throws Exception {
        Person person = new Person();
        person.sayHello();

        Class cls = Class.forName("demo1.Person");
        Object obj = cls.newInstance();
        Method m = cls.getMethod("sayHello");
        m.invoke(obj);

        AnnotationConfigApplicationContext context
                = new AnnotationConfigApplicationContext("demo1");
        Person p = context.getBean(Person.class);
        p.sayHello();
    }
}
